// retCode project retCode.go
package retCode

import (
	"encoding/json"
)

const (
	WebRetCodeSuccess           = "000000"
	WebRetCodeParamFailed       = "108100"
	WebRetCodeAppidNotExist     = "108101"
	WebRetCodeMqIsFull          = "108102"
	WebRetCodeOutOfLine         = "108103"
	WebRetCodeSystemWrong       = "108104"
	WebRetCodeCallIdNotExist    = "108105"
	WebRetCodeCommandDelay      = "108106"
	WebRetCodeFileIsNULL        = "108107"
	WebRetCodeNotProces         = "108108"
	WebRetCodeReqQcloudErr      = "108109"
	WebRetCodeNumberInvalid     = "108110" //号码无效
	WebRetCodeReqKernlErr       = "108111"
	WebRetCodeReqTimeOut        = "108112"
	WebRetCodeNumberInBlackList = "108113"
	recvMaxByte                 = 1048576 //1024*1024 1m
)

type ResultJson struct {
	Appid  string `json:"appId"`
	CallId string `json:"callId"`
	Ret    string `json:"code"`
}

func FailReturn(result chan *[]byte, webCode int, ret string, appid string, callid string) error {

	res := ResultJson{appid, callid, ret}

	resp, err := json.Marshal(res)
	if err != nil {
		return err
	}

	result <- &resp
	return nil
}
